<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Crud Example with Spring Hibernate</title>
	
	<script type="text/javascript" src="<c:url value="/resources/scripts/jquery.js"/>"></script>
    <script type="text/javascript" src="<c:url value="/resources/scripts/jquery.easyui.js"/>"></script>    
	<script type="text/javascript" src="<c:url value="/resources/scripts/jquery.pagination.js"/>"></script>
	<script type="text/javascript" src="<c:url value="/resources/scripts/site.js"/>"></script>
	<script type="text/javascript" src="<c:url value="/resources/scripts/wysiwyg/jquery.wysiwyg.js"/>"></script>
	
	<script type="text/javascript">
        $(document).ready(function() {
        	$("#btn-cari").click(function(){
				$("#form").submit();
			});
        });
    </script>
</head>

<body>
	
	
<form id="form" action="<c:url value="search"/>" enctype="multipart/form-data" method="post">
	<input type="hidden" name="offset" value="${pagingInfo.offset}"/>
	<input type="hidden" name="pageSize" value="${pagingInfo.pageSize}"/>
	<input type="hidden" name="totalRows" value="${pagingInfo.totalRows}"/>
	
	<div align="center">
	
		<div class="column">
    			<label style="font-size: 1.3em;margin-bottom: 0em;">Crud Example with Spring Hibernate</label>
		</div>
		
		<jsp:include page="message.jsp"></jsp:include>
		
		<div ></div><br/>
		
		<div  style="padding: 5px;" align="center">
			<table style="border-collapse: collapse;">
				<tr>
					<td>
						<label>Nama &nbsp;&nbsp; :</label>
				    	<input type="text" name="name"/>
					</td>
					<td rowspan="2">
						<a id="btn-cari" href="#">Cari</a>
					</td>
				</tr>
				<tr>
					<td>
						<label>Alamat &nbsp;:</label>
				    	<input type="text" name="address"/>
				    </td>
				</tr>
			</table>
	    </div>
	    
	    <div class="column">
   			<a href="<c:url value="open"/>">Tambah Data</a>
		</div>
			
	    <div ></div><br/>
	    
		<table style="border-collapse: collapse;" border="1" width="500">
	        <tr bgcolor="lightblue">
	        	<th>No</th>
	            <th>Id</th>
	            <th>Nama</th>            
	            <th>Alamat</th> 
	            <th></th>   
	        </tr>
	        <c:forEach var="simpleCrud" items="${simpleCruds}" varStatus="status">
				<tr>
					<td>${pagingInfo.offset + status.index + 1}</td>
					<td><a href="<c:url value="/simpleCrud/open?id=${simpleCrud.id}"/>">${simpleCrud.id}</a></td>
					<td>${simpleCrud.name}</td>
					<td>${simpleCrud.address}</td>
					<td><a href="<c:url value="/simpleCrud/delete?id=${simpleCrud.id}"/>">Hapus</a></td>
				</tr>
			</c:forEach>
	        <c:if test="${empty simpleCruds}">
				<tr><td colspan="5" align="center">Tidak ada data ditemukan..</td></tr>
			</c:if>
			<tr class="footer">
                <td colspan="7">
                    <div class="pagination"></div>
				</td>
			</tr>          
    	</table>   
	</div>
</form>
</body>
</html>
